package com.xhs.main.controller.rsb;

import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * @author author
 * @create 2020-10-20-12:08
 */
public class DateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String string) {
        if(string!=null&&!string.isEmpty()) {

            try {
                DateFormat dt=new SimpleDateFormat("yyyy-MM-dd");
                Date date = dt.parse(string);
                return date;
            } catch (ParseException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
        return null;
    }
}

